<template name="trailerStars">
	<view class="movie-score-wapper">
		<image v-for="yello in yelloScore" class="star-icon" src="../static/icos/star-yellow.png" mode=""></image>
		<!-- <image class="star-icon" src="../static/icos/star-yellow.png" mode=""></image>
		<image class="star-icon" src="../static/icos/star-yellow.png" mode=""></image>
		<image class="star-icon" src="../static/icos/star-yellow.png" mode=""></image> -->
		<image v-for="gray in grayScore" class="star-icon" src="../static/icos/star-gray.png" mode=""></image>
		<view v-if="showNum==1" class="movie-score">
			{{innerScore}}
		</view>
	</view>
</template>

<script>
	export default {
		name: "trailerStars", //定义组件的名称为helloComp
		data() {
			return {
				yelloScore:0,
				grayScore:5
			};
		},
		//组件创建完成后被调用
		created() {
			var tempScore=0;
			if(this.innerScore!=null&&this.innerScore!=undefined&&this.innerScore!=""){
				tempScore=this.innerScore;
			}
			var yelloScore=parseInt(tempScore/2);
			var grayScore=5-yelloScore;
			
			this.yelloScore=yelloScore;
			this.grayScore=grayScore;
		},
		props: {
			// 定义一个变量,接收父组件的数据
			myValue: {
				type: String
			},
			innerScore:0,
			showNum:0 //是否显示分数
			
		}
	}
</script>

<style>
	.movie-score-wapper {
		display: flex;
		flex-direction: row;
	}

	.star-icon {
		width: 20rpx;
		height: 20rpx;
		margin-top: 10rpx;
	}

	.movie-score {
		font-size: 15px;
		color: grey;
		margin-left: 10rpx;
	}
</style>
